package com.dailyblue.java.cloud.customer.feign.controller;

import com.dailyblue.java.cloud.commons.util.JsonResult;
import com.dailyblue.java.cloud.customer.feign.service.ProviderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Resource
    private ProviderService providerService;

    @GetMapping("/a")
    public JsonResult a() {
        log.info("访问了feign的a");
        return providerService.a();
    }

    @GetMapping("/b")
    public JsonResult b() {
        return providerService.b();
    }

    @GetMapping("/c")
    public JsonResult c() {
        return providerService.c();
    }

    @GetMapping("/d1")
    public JsonResult d1() {
        return providerService.d();
    }

    @GetMapping("/d2")
    public JsonResult d2() {
        return providerService.d();
    }

    @GetMapping("/e")
    public JsonResult e() {
        int r = (int) (Math.random() * 3);
        System.out.println(9 / r);
        return providerService.a();
    }

    @GetMapping("/e1")
    public JsonResult e1() {
        return providerService.e();
    }

    @GetMapping("/f")
    public JsonResult f() {
        return providerService.f();
    }
}
